package org.hsieh.tr.explore.db;

import java.sql.Connection;

public enum ETranscanIsolationLevel {

    READ_UNCOMMITTED(Connection.TRANSACTION_READ_UNCOMMITTED,
	    "Read uncommitted"), READ_COMMITED(
	    Connection.TRANSACTION_READ_COMMITTED, "Read committed"), REPEATABLE_READ(
	    Connection.TRANSACTION_REPEATABLE_READ, "Repeatable read"), SERIALIZABLE(
	    Connection.TRANSACTION_SERIALIZABLE, "Serializable");

    private final int level;
    private final String levelName;

    ETranscanIsolationLevel(int level, String levelName) {
	this.level = level;
	this.levelName = levelName;
    }

    public int getLevel() {
	return level;
    }

    public String getLevelName() {
	return levelName;
    }

    public static ETranscanIsolationLevel getLevelBy(int level) {
	for (ETranscanIsolationLevel el : values()) {
	    if (el.level == level)
		return el;
	}
	return null;
    }

}
